<?php
use Dotenv\Dotenv;

/*
|--------------------------------------------------------------------------
| Detect The Application Environment
|--------------------------------------------------------------------------
|
| Laravel takes a dead simple approach to your application environments
| so you can just specify a machine name for the host that matches a
| given environment, then we will automatically detect it for you.
|
*/

$env = $app->detectEnvironment(function(){
    $environmentPath = __DIR__.'/../.env';
    if (file_exists($environmentPath))
    {
        $setEnv = trim(file_get_contents($environmentPath));

        putenv('APP_ENV='.$setEnv);

        // LARAVEL 5.8  - use this below..
        $paths = __DIR__ . '/../';
        $file = '.env'.'.' . getenv('APP_ENV');
        $dotenv = Dotenv::create($paths, $file);
        $dotenv->overload(); //this is important
    }
});

?>